package microcredit.gui.editor.loan;

import javax.swing.JScrollPane;

import net.miginfocom.swing.MigLayout;
import microcredit.gui.editor.AbstractEditorForm;
import microcredit.gui.table.BeanTable;
import microcredit.gui.table.TableFactory;
import microcredit.model.MemberToLoan;
import microcredit.model.MemberToLoanHistory;

public class LoanHistoryForm extends AbstractEditorForm<MemberToLoan> {

	private BeanTable<MemberToLoanHistory> table;
	
	public LoanHistoryForm() {
		initialize();
		setTitle("History");
	}
	
	@Override
	public void apply(MemberToLoan e) throws Throwable {
		table.load(e.getValidMemberToLoanHistories());
	}

	@Override
	public MemberToLoan receive(MemberToLoan e) throws Throwable {
		return e;
	}
	

	private void initialize() {
		setLayout(new MigLayout("wrap", "[grow, fill]", "[grow, fill]"));
		table = TableFactory.create(MemberToLoanHistory.class);
		add(new JScrollPane(table));
	}
	
}
